#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Thu Aug 26 00:00:55 2021

@author: liqingsimac
"""

##Example 6-3-7
import numpy as np
import matplotlib.pyplot as plt

def myfun(C1,C2,x):
    y=(C1+C2*x)*np.exp(-2*x)+np.sin(2*x)/8
    return y

C1=0
C2=[-3,-2,-1,-1/2,0,1/2,1,2,3]

a=3; N=101
x=np.linspace(0,a,N)

fig=plt.figure()
ax=fig.add_subplot(111)
for k in range(len(C2)):
    y=myfun(C1,C2[k],x)
    ax.plot(x,y,'b-')

#ax.set_aspect('equal')
ax.set_xlabel('x')
ax.set_ylabel('y')
ax.set_title(r'integral curves with $y(0)=0$ and different $y^\prime(0)$')
ax.annotate(r'$\frac{d^2y}{dx^2}+4\frac{dy}{dx}+4y=\cos 2x.$',xy=(1.5,0.5))
fig.savefig('ode-example-6-3-7.png')
